Skip to main content

Sugar - Sound Sensor Module

Sugar Cube Sound Intensity Module.png

Functions


Signal:Analog output0~3.3V Corresponding to the Future Board Lite0~4096

Module Principle

The sound sensor works based on the principle of piezoelectricity. When a sound wave hits the surface of the sensor, the piezoelectric material inside the sensor generates a tiny charge change, which can be measured and converted into a digital signal. In addition, the sound sensor also requires a pre-amplifier to amplify the charge change signal and filter out other types of interference signals.

Wiring

Futublock Lite Mainboard 3 - Copy.png

Futublock Lite InterfaceCable
Sugar Cube Sound Intensity Module.pngSugar Cube Sound Sensor ModulePort3White PH2.0-3Pin Interface Cableuntitled.100.png

warning Support connecting to Port1, Port2, Port3, Port4 Pay attention to the consistency of interface and actual situation when programming

Blocks - Function Description

No.Block ImageBlock Function
1image-20240316161337435Reads the output value of the module, range 0-4096, the louder the sound, the greater the value
2image-20240316161319076Converts value, mapping method is
output=100x(60-0)/(4096-0)

Block 1 - Full program

blocksPng-1710578213621

Block 1 - Function Description

Set the color screen to full color pixel mode, and turn off the auto refresh mode. blocksPng-1710578233232

warning Read the value of sound sensor, and set a threshold, when the value is over the threshold, the screen displays red, otherwise displays green. The threshold can be modified according to the actual situation. blocksPng-1710578238076

tips Display the value of sound sensor on the color screen. blocksPng-1710578242356

Program 2 - Complete Program

blocksPng-1710578523865

Block 2 - Functions Explained

warning Set the display to full color pixel mode and turn off auto refresh mode.

blocksPng-1710578568972

Draw three concentric circles that represent three levels of sound. blocksPng-1710578574198

Convert the value from the sound sensor to a value that can be displayed as the radius of a circle on the screen.

  • How mapping works

For example, if the value of x is between 0 and 4096. Our display can't show a rectangle with a height of 4096 pixels, but it can show a rectangle with a maximum height of 100 pixels. We can use mapping to convert the value to a smaller number.

Let's say the current reading from the raindrop water level sensor is X = 2000. Using the mapping parameters in the diagram, we get = 2000x((60-0)/(4096-0))=29.296 Since the display variable does not support displaying decimals directly, we convert it to an integer.

blocksPng-1710578578495

Using Kittenblock

Run the program offline to view the effect

Using on Microbit

Robotbit_压缩后.png

Programming Platform

Microsoft MakeCode for micro:bit Programming with MakeCode platform

Add the Sugar plugin

image-20240311154521941 image.png

Search Sugar in the extensions, click Add